package com.ll.domain.classbase.convert;

import com.ll.app.api.req.AddCourseReqDTO;
import com.ll.dal.po.CoursePO;
import com.ll.domain.classbase.dto.CourseDTO;
import com.ll.domain.classbase.enums.CourseStatusEnum;
import org.springframework.beans.BeanUtils;

public class CourseConvert {
    public static CourseDTO PO2DTO(CoursePO po) {
        CourseDTO dto = new CourseDTO();
        BeanUtils.copyProperties(po, dto);
        dto.setStatusCode(po.getStatus().ordinal());
        dto.setTypeCode(po.getType().ordinal());
        return dto;
    }

    public static CoursePO DTO2PO(CourseDTO dto) {
        CoursePO po = new CoursePO();
        BeanUtils.copyProperties(dto, po);
        return po;
    }

    public static CoursePO addCourseReqDTO2PO(AddCourseReqDTO reqDTO){
        CoursePO po = new CoursePO();
        BeanUtils.copyProperties(reqDTO, po);
        po.setStatus(CourseStatusEnum.未开始);
        po.setApplicants(0);
        return po;
    }

}
